﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RMSoftware.Models;
using Entities;

namespace RMSoftware.Controllers
{
    public class RiskFactorController : Controller
    {
        [HttpGet]
        public ActionResult ViewList()
        {
            DataManager dm = new DataManager();

            ViewData.Model = dm.RiskFactors;

            return View();
        }

        [HttpGet]
        public ActionResult ViewDetails(Guid id)
        {
            return View((new DataManager()).GetRiskFactor(id));
        }

        [HttpPost]
        public ActionResult Create(RiskFactor obj)
        {
            obj.RiskId = Guid.NewGuid();
            (new DataManager()).AddRiskFactor(obj);

            return RedirectToAction("ViewList");
        }

        [HttpGet]
        public ActionResult Create()
        {
            return View();
        }

        [HttpGet]
        public ActionResult Delete(Guid id)
        {
            (new DataManager()).DeleteRiskFactor(id);

            return RedirectToAction("ViewList");
        }

        [HttpGet]
        public ActionResult Modify(Guid id)
        {
            return View((new DataManager()).GetRiskFactor(id));
        }

        [HttpPost]
        public ActionResult Modify(RiskFactor obj)
        {
            (new DataManager()).SaveRiskFactor(obj);

            return RedirectToAction("ViewDetails", "RiskFactor", new { id = obj.RiskId });
        }
    }
}
